package offerv1;

import java.util.Arrays;

public class Offer61 {
    public static void main(String[] args) {
        Offer61 offer61 = new Offer61();
        offer61.isStraight(new int[]{0, 0, 8, 5, 4});
    }

    public boolean isStraight(int[] nums) {
        Arrays.sort(nums);
        int n = nums.length;
        int count = 0, last = 0;
        for (int i = 0; i < n; i++) {
            if (nums[i] == 0) {
                count++;
                continue;
            }

            if (i > 0) {
                if (nums[i] == nums[i - 1]) return false;
                else if (nums[i - 1] != 0) last += nums[i] - nums[i - 1] - 1;
            }
        }
        return count >= last;
    }
}
